package Mailbox;

import java.io.File;
import java.net.Socket;
import java.util.Vector;

public class MailboxFTP {
	private File file = null;
	private boolean isSet = false;

	// private Socket sender;

	public synchronized void saveFile(File file) {
		// Not needed here. Otherwise it will lock and halt the program.
		// while (isSet) {
		// try {
		// wait();
		// } catch (InterruptedException e) {
		// e.printStackTrace();
		// }
		// }

		this.file = file;
		isSet = true;
		notifyAll();


	}

	public synchronized File removeFile() {
		while (!isSet) {
			try {
				wait();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}

		File temp = file;
		file = null;
		isSet = false;
		notifyAll();

		return temp;

	}

}
